<?php

class ProductscAction extends SCAction {
    public function plist(){
      //  $this->name = 'thinkphp'; // 进行模板变量赋值
	    $Data = M('Products_index'); // 实例化Data数据模型
        $this->data = $Data->select();
//	    $Data = M('index'); // 实例化Data数据模型		
        $this->display();

    }

	public function update(){
    $Form   =   D('Products_index');
    if($Form->create()) {
        $result =   $Form->save();
        if($result) {
            $this->success('操作成功！');
        }else{
            $this->error('写入错误！');
        }
    }else{
        $this->error($Form->getError());
    }
}
   public function insert(){
        $Form   =   D('Products_index');
        if($Form->create()) {
            $result =   $Form->add();
            if($result) {
                $this->success('操作成功！');
            }else{
                $this->error('写入错误！');
            }
        }else{
            $this->error($Form->getError());
        }
    }
	public function del($id=-1){
    $Form   =   M('Products_index');
    $Info   =   M('Products');
     
    if($Form->delete($id)===false || $Info->where('pid='.$id)->delete()===false ) {
		$this->error('数据错误');
    }else{
	    $this->success('删除'.$id.'成功');// 模板变量赋值
        
    }
}
}
?>